package com.ruoyi.system.controller;

import cn.xiaosiyuan.util.genId.PKGenerator;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbWorkProjectDemandRecord;
import com.ruoyi.system.service.ITbWorkProjectDemandRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目需求记录Controller
 * 
 * @author xiaosiyuan
 * @date 2021-11-19
 */
@RestController
@RequestMapping("/system/projectDemandRecord")
public class TbWorkProjectDemandRecordController extends BaseController
{
    @Autowired
    private ITbWorkProjectDemandRecordService tbWorkProjectDemandRecordService;

    /**
     * 查询项目需求记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectDemandRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbWorkProjectDemandRecord tbWorkProjectDemandRecord)
    {
        startPage();
        List<TbWorkProjectDemandRecord> list = tbWorkProjectDemandRecordService.selectTbWorkProjectDemandRecordList(tbWorkProjectDemandRecord);
        return getDataTable(list);
    }

    /**
     * 导出项目需求记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectDemandRecord:export')")
    @Log(title = "项目需求记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbWorkProjectDemandRecord tbWorkProjectDemandRecord)
    {
        List<TbWorkProjectDemandRecord> list = tbWorkProjectDemandRecordService.selectTbWorkProjectDemandRecordList(tbWorkProjectDemandRecord);
        ExcelUtil<TbWorkProjectDemandRecord> util = new ExcelUtil<TbWorkProjectDemandRecord>(TbWorkProjectDemandRecord.class);
        return util.exportExcel(list, "项目需求记录数据");
    }

    /**
     * 获取项目需求记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:projectDemandRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbWorkProjectDemandRecordService.selectTbWorkProjectDemandRecordById(id));
    }

    /**
     * 新增项目需求记录
     */
    @PreAuthorize("@ss.hasPermi('system:projectDemandRecord:add')")
    @Log(title = "项目需求记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbWorkProjectDemandRecord tbWorkProjectDemandRecord)
    {
        tbWorkProjectDemandRecord.setId(PKGenerator.newId());
        return toAjax(tbWorkProjectDemandRecordService.insertTbWorkProjectDemandRecord(tbWorkProjectDemandRecord));
    }

    /**
     * 修改项目需求记录
     */
    @PreAuthorize("@ss.hasPermi('system:projectDemandRecord:edit')")
    @Log(title = "项目需求记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbWorkProjectDemandRecord tbWorkProjectDemandRecord)
    {
        return toAjax(tbWorkProjectDemandRecordService.updateTbWorkProjectDemandRecord(tbWorkProjectDemandRecord));
    }

    /**
     * 删除项目需求记录
     */
    @PreAuthorize("@ss.hasPermi('system:projectDemandRecord:remove')")
    @Log(title = "项目需求记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbWorkProjectDemandRecordService.deleteTbWorkProjectDemandRecordByIds(ids));
    }
}
